home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / bitblt.c < prev    next >
C/C++ Source or Header  |  1994-05-22  |  3KB  |  98 lines

  1. /* Copyright (C) 1994 Free Software Foundation
  2.  
  3. This file is part of the GNU BitString Library.  This library is free
  4. software; you can redistribute it and/or modify it under the
  5. terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8.  
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with GNU CC; see the file COPYING.  If not, write to
  16. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. As a special exception, if you link this library with files
  19. compiled with a GNU compiler to produce an executable, this does not cause
  20. the resulting executable to be covered by the GNU General Public License.
  21. This exception does not however invalidate any other reasons why
  22. the executable file might be covered by the GNU General Public License. */
  23.  
  24. /*  Written by Per Bothner (bothner@cygnus.com).
  25.     Based on ideas in the X11 MFB server. */
  26.  
  27. #include "bitprims.h"
  28. #define ONES ((_BS_word)(~0))
  29.  
  30. /* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT.
  31.    This will work even if psrc & pdst overlap. */
  32.  
  33. void
  34. _BS_blt (op, pdst, dstbit, psrc, srcbit, length)
  35.      enum _BS_alu op;
  36.      register _BS_word* pdst;
  37.      int dstbit;
  38.      register const _BS_word* psrc;
  39.      int srcbit;
  40.      _BS_size_t length;
  41. {
  42.   _BS_word ca1, cx1, ca2, cx2;
  43.   switch (op)
  44.     {
  45.     case _BS_alu_clear:
  46.       _BS_clear (pdst, dstbit, length);
  47.       return;
  48.     case _BS_alu_and:
  49.       _BS_and (pdst, dstbit, psrc, srcbit, length);
  50.       return;
  51.     case _BS_alu_andReverse:
  52.       ca1 = ONES; cx1 = 0; ca2 = ONES; cx2 = 0;
  53.       break;
  54.     case _BS_alu_copy:
  55.       _BS_copy (pdst, dstbit, psrc, srcbit, length);
  56.       return;
  57.     case _BS_alu_andInverted:
  58.       ca1 = ONES; cx1 = ONES; ca2 = 0; cx2 = 0;
  59.       break;
  60.     case _BS_alu_noop:
  61.       return;
  62.     case _BS_alu_xor:
  63.       _BS_xor (pdst, dstbit, psrc, srcbit, length);
  64.       return;
  65.     case _BS_alu_or:
  66.       ca1 = ONES; cx1 = ONES; ca2 = ONES; cx2 = 0;
  67.       break;
  68.     case _BS_alu_nor:
  69.       ca1 = ONES; cx1 = ONES; ca2 = ONES; cx2 = ONES;
  70.       break;
  71.     case_BS_alu_equiv:
  72.       ca1 = 0; cx1 = ONES; ca2 = ONES; cx2 = ONES;
  73.       break;
  74.     case _BS_alu_invert:
  75.       _BS_invert (pdst, dstbit, length);
  76.       return;
  77.     case _BS_alu_orReverse:
  78.       ca1 = ONES; cx1 = ONES; ca2 = 0; cx2 = ONES;
  79.       break;
  80.     case _BS_alu_copyInverted:
  81.       ca1 = 0; cx1 = 0; ca2 = ONES; cx2 = ONES;
  82.       break;
  83.     case _BS_alu_orInverted:
  84.       ca1 = ONES; cx1 = 0; ca2 = ONES; cx2 = ONES;
  85.       break;
  86.     case _BS_alu_nand:
  87.       ca1 = ONES; cx1 = 0; ca2 = 0; cx2 = ONES;
  88.       break;
  89.     case _BS_alu_set:
  90.       _BS_set (pdst, dstbit, length);
  91.       return;
  92.     }
  93.   {
  94. #define COMBINE(dst, src)  ((dst) & ((src) & ca1 ^ cx1) ^ ((src) & ca2 ^ cx2))
  95. #include "bitdo2.h"
  96.   }
  97. }
  98.